#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;

int n, k;
int a[123123];
int was[12312];
vector <pair <int , int > > all;


void load()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		all.pb(mp(a[i], i));
	}
	int q, x;
	cin >> q;
	ldb mx = -1e42;
	ldb mn = 1e42;
	int cnt = 0;
	for (int i = 0; i < q; i++)
	{
		int sum = 0;
		for (int j = 0; j < n / k; j++)
		{
			scanf("%d", &x);
			sum += a[x - 1];
			if (j == 0 && was[x - 1] == 0)
			{
				cnt++;
			}
			was[x - 1] = 1;
		}
		mx = max(mx, sum / (ldb)(n / k));
		mn = min(mn, sum / (ldb)(n / k));
	}
	sort(all.begin(), all.end());
	if (cnt < k)
	{
	int sum = 0;
	int j = 0;
	for (int i = 0; i < all.size() && j < n / k; i++)
	{
		if (was[all[i].ss]) continue;
		sum += all[i].ff;
		j++;
	}
	if (j == n / k)
		mn = min(mn, sum / (ldb)(n / k));
	sum = 0;
	j = 0;
	for (int i = all.size() - 1; i >= 0 && j < n / k; i--)
	{
		if (was[all[i].ss]) continue;
		sum += all[i].ff;
		j++;
	}
	if (j == n / k)
		mx = max(mx, sum / (ldb)(n / k));
	}
	cout << setprecision(15) << fixed << mn << " " << mx;
	
}

void solve()
{

}

#define file "b"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	load();
	solve();
	return 0;
}
